const api = window.$api.workflow.process;
export default function () {
  return {
    data() {
      return {
        isCreateAgain: false,
        isCreateSub: false,

        processId: '',

        taskId: '',
        title: '',
        visible: false
      }
    },
    methods: {
      handleOpen(row) {
        if (this.type == 'uncompleted') {
          this.isCreateAgain = row.f_Type == 4 ? true : false;
          this.isCreateSub = row.f_Type == 3 ? true : false;
          this.taskId = row.wf_f_Id;
          this.title = `${row.f_ProcessTitle}【${row.wf_f_UnitName}】`;

        }
        else if (this.type == 'my') {
          this.title = row.wf_f_Title
          this.processId = row.wf_f_Id
        }
        if (this.type == 'completed') {
          this.taskId = row.wf_f_Id;
          this.title = `${row.f_ProcessTitle}【${row.wf_f_UnitName}】`;
        }
        this.visible = true;

      },
      handleRevoke($index, row) {
        this.$confirm('是否撤销审核?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          api.revokeAudit(row.wf_f_ProcessId, row.wf_f_Id).then(() => {
            this.loadTableData(this.tableTotal > 1)
            this.$message({
              type: 'success',
              message: '撤销成功!'
            })
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消撤销'
          })
        })
      },

    }
  }
}